﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using CRMBiz;
using CRMWeb.Utilities.Context;

namespace CRMWeb.Pages.AM.EzidebitService
{
    public partial class EditBankAccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                string digitalKey = WebConfigurationManager.AppSettings["EziDebitDigitalKey"].ToString();
                var crRef = txtCusRefE.Text;
                if (digitalKey != null & crRef != null)
                {
                    StringBuilder sb = new StringBuilder();
                    //Edit bank details for payment
                    sb.Append("<script language='javascript'>window.open('https://widget.demo.ezidebit.com.au/account/Edit?dk=" + digitalKey + "&er=" + crRef + "', 'List', 'left = 300,top=150,scrollbars=no, resizable=no,width=500,height=450');</script>");
                    if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                        ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.saveErrorLog(ex, CMSContext.CurrentUser.MemberName);
            }
        }
    }
}